<?php 
$GLOBALS['Md'] = "TimeClock";
$GLOBALS['Pd'] = "B";
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
print heade(); 
print body(); 
module($BSD['DB00']);
office_header($_SESSION[$SESSOF]);
include($GLOBALS['PAD']."Modules/TimeClock/main.obj.php");
include($GLOBALS['PAD']."Modules/TimeClock/nav.views.php");
print NavBack();

if (isset($_POST['Save'])) {

	$Ref = $_POST['ref'];
	$Status = $_POST['Status'];
	$Count = count($Ref);
	for ($r = 0; $r < $Count; $r++) {

		if ($Status[$r] != 1 && $Status[$r] != 2) {
				$QValidate = "UPDATE timeclock_delays 
				SET Status = {$Status[$r]}
				WHERE ref = {$Ref[$r]}";
				$GLOBALS['CONN']->db_query($QValidate); 
		}
	}

} 
?>
<script charset="utf-8" type="text/javascript" src="../../../Shared/Libraries/JS/calendar.js"></script> 
<table width="100%"  border="0" cellpadding="10">
  
  <tr>
    <td><table width="100%"  border="0" cellpadding="3" cellspacing="1">
        <tr bgcolor="#99CCCC">
          <td bgcolor="#99CCCC">Férias Atribuidas </td>
          </tr>
    </table>
      <br>  
	 <form action="delays.php" method="post">
	<table width="100%"  border="0" cellpadding="3" cellspacing="1">
	
        <tr bgcolor="#F2F2F2">
          <td>Funcionário</td>
          <td width="20%">Início</td>
          <td width="50%">Fim</td>
          <td width="10%">Estado</td>
        </tr>
   <?php
    $QNavTime = "SELECT timeclock_vacs.ref,timeclock_vacs.TimeStart,timeclock_vacs.TimeEnd,timeclock_vacs.Status, main_users.name FROM timeclock_vacs
	INNER JOIN main_users ON main_users.ref = timeclock_vacs.RefUser
	WHERE Status IN (1,2,3)
	ORDER BY TimeStart DESC";
	$NavTime = $GLOBALS['CONN']->db_array($QNavTime); 
	for ($f = 1; $f <= $NavTime[0]; $f++) { ?>
        <tr bgcolor="#F8F8F8">
          <td>
		  <input type="hidden" value="<?php echo $NavTime[$f]['ref'];?>" name="ref[]">
		  <?php echo $NavTime[$f]['name'];?></td>
          <td><?php echo $NavTime[$f]['TimeStart'];?></td>
          <td><?php echo $NavTime[$f]['TimeEnd'];?></td>
          <td><?php echo $NavTime[$f]['Status'];?></td>
        </tr>
	<?php } ?>
    </table>
	<input name="Save" type="submit" id="Save" value="Salvar">
	</form>
</td>
  </tr>
</table>
<?php print footer(); ?>